import axios from 'network/request.js'
// 获取权限列表
export function getRightsList () {
  return axios({
    method: 'get',
    url: '/rights/list'
  })
}
// 获得所有角色
export function getRoles () {
  return axios({
    url: '/roles'
  })
}
// 删除角色拥有的权限
export function deleteRight (roleId, rightId) {
  return axios({
    method: 'delete',
    url: `/roles/${roleId}/rights/${rightId}`
  })
}
// 获取所有权限数据(tree结构)
export function getRightsTree () {
  return axios({
    url: '/rights/tree'
  })
}
// 为角色分配权限
export function upadteRight (roleId, rightIds) {
  return axios({
    method: 'post',
    url: `/roles/${roleId}/rights`,
    data: {
      rids: rightIds
    }
  })
}
// 添加角色
export function addRole (data) {
  return axios({
    method: 'post',
    url: '/roles',
    data
  })
}
// 根据id查询角色
export function getRoleById (id) {
  return axios({
    url: `/roles/${id}`
  })
}
// 修改角色
export function editRoleInfo (id, data) {
  return axios({
    method: 'put',
    url: `roles/${id}`,
    data
  })
}
// 删除角色
export function deleteR (id) {
  return axios({
    method: 'delete',
    url: `roles/${id}`
  })
}
